package org.myorg.v3;

import java.util.Arrays;

import org.myorg.Gene;
/*
Formulation:

Minimize:
f(x) = sum((10^6)^((i-1)/(D-1))*x(i)^2)

-100 <= x(i) <= 100

global minimum

f(x) = 0
x(i) = 0, i=1:n
 */
public class FFZ231 extends Fc3 {
	
	public double[] z; 

	public FFZ231(int dim) {
/*		low = -32.378;
		high = 32.378;*/
		low = -10000;
		high = 10000;
		z = new double[dim];
		for (int i = 0; i < z.length; i++) {
//			z[i] = (high - low)*Math.random() + low;
//			System.out.println("z " + i + " is:" + z[i]);
			z[i] = 0;
			System.out.println("z " + i + " is:" + z[i]);
		}
		
		best = Double.NEGATIVE_INFINITY;
	}
	
	public void init() {
		mark = new boolean[data.length];
		for (boolean bm : mark) {
			bm = false;
		}
		count = 0;
	}
	
	public double getBest() {
		return best;
	}



	public void setBest(double best) {
		this.best = best;
	}



	public boolean getMark(int i) {
		return mark[i];
	}



	public void setMark(boolean m, int i) {
		mark[i] = m;
	}



	public int getCount() {
		return count;
	}



	public void setCount(int count) {
		this.count = count;
	}



	public double fc(double[] tmp) {
		double y = 0;
		
		double n = tmp.length;
		
		//double t1 = Math.pow(Math.pow(10, 6), 1);
		//System.out.println("best gene from function " + tmp[0]);	
		//y = (tmp[0]-z[0])*(tmp[0]-z[0]);
				
		for (int i = 0; i < n; i++ ) {
			y = y +(tmp[i]-z[i])*(tmp[i]-z[i]);
		}
		
		return y;
	}

}



